var moment = require('moment');

exports.formatDate = function (date) {
	var diffMinutes = moment().diff(date, 'minutes', true);
	var diffHours = moment().diff(date, 'hours', true);
	var dateFormatted = '';
	if (diffMinutes < 1)
		dateFormatted = '刚刚';
	else if (diffMinutes < 60)
		dateFormatted = ~~diffMinutes + '分钟之前';
	else if (diffHours < 24)
		dateFormatted = ~~diffHours + '小时之前';
	else
		dateFormatted = moment(date).format('YYYY年MM月DD日');
	return dateFormatted;
}